package com.books.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.books.entity.Books;
import com.books.entity.Type;
import com.books.mapper.BookMapper;
import com.books.service.IBookService;
import com.books.vo.Book;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BookServiceImpl extends ServiceImpl<BookMapper,Book> implements IBookService {

    @Autowired
    private BookMapper bookMapper;

    @Override
    public List<Book> getAll() {
        return bookMapper.getAll();
    }

    @Override
    public List<Book> getPage_2(Integer c, Integer s) {
        return bookMapper.getPage_2(c,s);
    }

    @Override
    public IPage<Book> getPage_1(Integer c, Integer s) {

        Page<Book> page = new Page<>(c, s);
        IPage<Book> page_1 = bookMapper.getPage_1(page);
        return page_1;

    }

    @Override
    public IPage<Book> getPageTpye(Integer c, Integer s, Integer type) {

        Page<Book> page = new Page<>(c, s);
        IPage<Book> pageTpye = bookMapper.getPageTpye(page, type);
        return pageTpye;
    }

    @Override
    public IPage<Book> getPageName(Integer c, Integer s, String name) {
        name = "%"+name+"%";
        Page<Book> page = new Page<>(c, s);
        IPage<Book> pageName = bookMapper.getPageName(page, name);
        return pageName;
    }

    @Override
    public Boolean addBook(Book book) {
        Books books = new Books(
                book.getId(),
                book.getName(),
                book.getNum(),
                book.getIntroduce(),
                book.getAdd_date()
        );

        return null;
    }

    @Override
    public Boolean deleBook(int id) {
        return null;
    }

    @Override
    public Boolean updateBook(Book book) {
        return null;
    }
}
